﻿using MediatR;
using SupplyChain.Domain.Entities;
using SupplyChain.Infrastructure.Interface;
using SupplyChain.Write.API.Application.Command.CustomerOrder;
using SupplyChain.Write.API.Application.Command.PurchaseOrder;

namespace SupplyChain.Write.API.Application.CommandHandler.CustomerOrder
{
    public class GetContractCategoryHandler : IRequestHandler<GetContractCategoryCommand, List<ContractCategory>>
    {
        private readonly IBaseRepository<ContractCategory> repository;

        public GetContractCategoryHandler(IBaseRepository<ContractCategory> repository)
        {
            this.repository = repository;
        }

        public async Task<List<ContractCategory>> Handle(GetContractCategoryCommand request, CancellationToken cancellationToken)
        {
            List<ContractCategory> categories = await repository.GetByWhereAsync(x => !x.IsDel);
            return await Task.FromResult(categories);
        }
    }
}
